An exception occurred when instantiating a Java object. The class must
not be an interface or an abstract class. Error: ''.
The same code, using javaloader to create() an object of the same
class runs successfully on CF 8 and CF 9.
Running it on Railo 3 produces the same error as the CF classpath.
The class in question is the ErrorReporter. The error is thrown on the
init of the JavaScriptCompressor, the reporter is created successfully
prior to that. (Even though it is just an interface, and no init
method is specified)
inputStream =
createObject('java','java.io.StringReader').init(inputString);
reporter = create('org.mozilla.javascript.ErrorReporter');
JavaScriptCompressor =
create('com.yahoo.platform.yui.compressor.JavaScriptCompressor').init(inputStream,reporter);
org.mozilla.javascript.ErrorReporter' is an interface.
The fact that it works at all was surprising too me.
I would really like to get to the bottom of this and be able to offer
a solution that runs on all platforms.
I am no expert with Java or the underlying CF class loader system and
would appreciate any feedback.
The YUICompressor jar and java src can be found at:
http://yuilibrary.com/downloads/yuicompressor/yuicompressor-2.4.2.zip
To me it seemed like a conflict of pre-loaded libraries in the CF
classpath.
I have verified another instance of
org.mozilla.javascript.ErrorReporter in one of the other jars.
That is why I assumed it worked with JavaLoader.
But not working on Railo with JavaLoader made me wonder if Railo and
JavaLoader have something different going on with respect to loading
the existing coldfusion libraries.
Which led me to try creating the same implementation the YUI java
source used to create the object.
I created a java class of the same type but different package.
Created the jar and threw it in the cf classpath.
Changed my code to create one of my new classes and passed that in,
and got the same error, about it being an interface or an abstract
class.
My next move would be to repackage the YUICompressor jar, but before I
do that the big question to me is...
How did JavaLoader get it to work? What is it doing? Got to be a way
to mimic it?
On Mar 5, 12:20 am, Mark Mandel <mark.man...@gmail.com> wrote:
> Thanks for that Matt - but I'm looking for the JavaDoc documentation.
>
> Tom - first thing I would do is generate the JavaDoc documentation, so you
> can browse how the library is implemented. Browsing source for this is
> tough.
>
> Secondly, if ErrorReporter is an interface - yes, you can't create one. It's
> an interface.
>
> ColdFusion does have a 'feature' is if you request an interface it will
> create an implementation for you that does nothing (i.e. not very useful).
> Railo is probably giving you back the more 'correct' error.
>
> If you do a javadoc of the library, you will be able to see what implements
> the ErrorReporter interface - I would expect that there is a default
> implementation with the library, and use that.
>
> Mark
>
>
>
> On Fri, Mar 5, 2010 at 10:12 AM, Matt Gersting <mgerst...@gmail.com> wrote:
> > Is this what you're looking for, Mark?
>
> >http://github.com/yui/yuicompressor/blob/0e290b8e05392f19bccc2f7d5247...
I can understand Railo's error being correct if it does not have the
feature that CF does for creating that skeleton interface object.
But what I can't understand is why it would not work on CF without
javaloader???
So I am taking a break with the CF classpath issue and focus on Railo
with JavaLoader.
The same code that works in CF with JavaLoader produces the following
error in railo:
No matching Constructor for
com.yahoo.platform.yui.compressor.JavaScriptCompressor(java.io.StringReader,
coldfusion.runtime.java.JavaProxy) found
There is nothing in the stack trace indicating what if anything
happened with the java code behind the scenes.
On Mar 5, 3:13 am, Mark Mandel <mark.man...@gmail.com> wrote:
> Tom,
>
> On Fri, Mar 5, 2010 at 1:04 PM, Tom de Manincor <tom.demanin...@gmail.com>wrote:
>
> > I can understand Railo's error being correct if it does not have the
> > feature that CF does for creating that skeleton interface object.
> > But what I can't understand is why it would not work on CF without
> > javaloader???
>
> Why does it matter? If you do it correctly (and follow the ideas I suggested
> below, you can get this working no problem).
>
> I think you're making this overly complicated.
>
> Mark
> --